// OGoMojo
// Whitemice.MOGI.RPC2.OwnedDocument
// License: LGPL
// Copyright: Whitemice Consulting, 2006
// Author(s): Adam Tauno Williams (awilliam@whitemice.org)
using System;
using CookComputing.XmlRpc;
using Whitemice.MOGI;

namespace Whitemice.MOGI.RPC2 {
	/// \brief Extends the document to include ownership attributes
	public abstract class OwnedDocument : Document, IOwnedDocument {
		/// \brief Constructor
		/// \param document An XmlRpcStruct document
		/// \param server Reference to server object		
		public OwnedDocument(XmlRpcStruct document, Whitemice.MOGI.RPC2.Server server) :
			base(document, server) {
		}

		/// \brief Return true			
		protected bool HasOwner {
			get {
				return true;
			}
		}
		
		/// \brief Return the owner.id value
		internal string OwnerId {
			get {
				return RPC2.ShortId((string)((XmlRpcStruct)document["owner"])["id"]);
			}
		}
		
		/// \brief Return the owner.login value
		protected string OwnerLogin {
			get {
				return (string)((XmlRpcStruct)document["owner"])["login"];
			}
		}
		
		/// \todo Implement
		public string Owner 
		{
			get { return "Document/Account/" + OwnerId; }
		}
	}
}